//
//  SearchBar.m
//  CMJWeibo
//
//  Created by BH on 16/1/7.
//
//

#import "SearchBar.h"
#import "UIImage+MJ.h"
#import "UIView+MJ.h"

@implementation SearchBar

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.background = [UIImage resizableImage:@"searchbar_textfield_background"];
        //文字垂直居中
        self.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        //右边显示一个清除按钮
        self.clearButtonMode = UITextFieldViewModeAlways;
        //左边显示搜索图标
        UIImageView *searchImg = [[UIImageView alloc] initWithImage:[UIImage imageWithName:@"searchbar_textfield_search_icon"]];
        searchImg.width = 35;
        searchImg.contentMode = UIViewContentModeCenter;
        self.leftView = searchImg;
        self.leftViewMode = UITextFieldViewModeAlways;
        //设置placehoder
        self.placeholder = @"搜索";
    }
    return self;
}

@end
